CFLAGS=-g -lpthread
CC=gcc

chat: main.o fifo.o chat_sig.o init
	$(CC) -o chat main.o fifo.o chat_sig.o $(CFLAGS)

main.o: main.c
	$(CC) -c -o main.o main.c $(CFLAGS)

chat_sig.o: chat_sig.c
	$(CC) -c -o chat_sig.o chat_sig.c $(CFLAGS)

fifo.o: fifo.c
	$(CC) -c -o fifo.o fifo.c $(CFLAGS)

init: init.c
	$(CC) -o init init.c

clean: 
	rm -rf *.o
	rm chat init

check: tests
	./tests
	rm tests

tests: check.o fifo.o chat_sig.o
	$(CC) $(CFLAGS) -o tests check.o fifo.o chat_sig.o
